//
//  HomeTableViewController.swift
//  swift_weibo
//
//  Created by ccl on 16/2/16.
//  Copyright © 2016年 LittleBoy. All rights reserved.
//

import UIKit

class HomeTableViewController: CCBaseTableViewVC {

    override func viewDidLoad() {
        super.viewDidLoad()
        virstorView?.setupViewInfo("visitordiscover_feed_image_house", labText: "关注一些人，回这里看看有什么惊喜", isHome: true);
       
        creatNavUI();
    
    }
   
    func creatNavUI(){
    
        let leftBtn = UIButton(type: UIButtonType.Custom);
        let leftBtnImage = UIImage(named: "navigationbar_friendsearch");
        leftBtn.setImage(leftBtnImage, forState: UIControlState.Normal);
        leftBtn.setImage(UIImage(named: "navigationbar_friendsearch_highlighted"), forState: UIControlState.Highlighted);
        leftBtn.addTarget(self, action: "navLeftBtnDidClick:", forControlEvents: UIControlEvents.TouchUpInside);
        leftBtn.frame.size = leftBtnImage!.size;
        navigationItem.leftBarButtonItem = UIBarButtonItem(customView: leftBtn);
        
        let reightBtn = UIButton(type: UIButtonType.Custom);
        let reightBtnImage = UIImage(named: "navigationbar_pop");
        reightBtn.setImage(reightBtnImage, forState: UIControlState.Normal);
        reightBtn.setImage(UIImage(named: "navigationbar_pop_highlighted"), forState: UIControlState.Highlighted);
        reightBtn.addTarget(self, action: "navReightBtnDidClick:", forControlEvents: UIControlEvents.TouchUpInside);
        reightBtn.frame.size = reightBtnImage!.size;
        navigationItem.rightBarButtonItem = UIBarButtonItem(customView: reightBtn);
        
        let titleBtn = CCHomeTitleBtn(type: UIButtonType.Custom);
        titleBtn.setTitle(shareUserAccount?.name, forState: UIControlState.Normal);
        titleBtn.setImage(UIImage(named: "navigationbar_arrow_down"), forState: UIControlState.Normal);
        titleBtn.setImage(UIImage(named: "navigationbar_arrow_up"), forState: UIControlState.Selected);
        titleBtn.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal);
        titleBtn.addTarget(self, action: "titleBtnDidClick:", forControlEvents: UIControlEvents.TouchUpInside);
       // titleBtn.frame.size = CGSizeMake(200, 30);
        titleBtn.sizeToFit();
        navigationItem.titleView = titleBtn;
        
        
        
    }
    
    func navLeftBtnDidClick(sender: UIButton){
       
        print("左边按钮点击了");
    }
    func navReightBtnDidClick(sender: UIButton){
        //print("navReightBtnDidClick");
        let saoMa = CCSaoMaVC();
        let saoMaNav = UINavigationController(rootViewController: saoMa);
        self.presentViewController(saoMaNav, animated: true, completion: nil);
        
    }
    func titleBtnDidClick(sender: UIButton){
       
        sender.selected = true;
        
        let popVC = CCPopViewVC();
        //设置转场代理
        let animationer = CCAnimationter();
        animationer.presentViewFrame = CGRectMake((view.frame.width - 100) * 0.5, 56, 100, 200);
        popVC.transitioningDelegate = animationer;
        
        // 设置转场动画模式 自定义
        popVC.modalPresentationStyle = UIModalPresentationStyle.Custom
        
        presentViewController(popVC, animated: true, completion: nil );
        
    }
    
    
    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated);
        virstorView?.strarRotation();
    }
    
 }


